import { reqGoodsInfo } from "@/api";

export default {
  state: {
    goodsInfo: {},
  },
  mutations: {
    UPDATE_GOODSINFO(state, goodsInfo) {
      state.goodsInfo = goodsInfo;
    },
  },
  actions: {
    async getGoodsInfo({ commit }, searchParams) {
      const result = await reqGoodsInfo(searchParams);
      if (result.code == 200) {
        commit("UPDATE_GOODSINFO", result.data);
      }
    },
  },
  getters: {
    goodsList(state) {
      return state.goodsInfo.goodsList || [];
    },
    trademarkList(state) {
      return state.goodsInfo.trademarkList || [];
    },
    attrsList(state) {
      return state.goodsInfo.attrsList || [];
    },
  },
};
